<template>
  <mt-navbar title="申请新增"> </mt-navbar>
  <view class="safety-150">
    <view class="bg-#FFF8F7 px-32rpx py-24rpx text-24rpx text-#F7775C mb-24rpx"> 申请新增后易盟客服将会在3个工作日内完成审核，请耐心等待。 </view>
    <view class="forms">
      <uv-form ref="formRef" label-position="left" label-width="200rpx" :border-bottom="false" :model="modelForm" :rules="rules">
        <uv-form-item label="产品名称：" prop="productName" required>
          <uv-input v-model="modelForm.productName" maxlength="50" placeholder="请输入产品名称" border="none" clearable></uv-input>
        </uv-form-item>

        <uv-form-item label="产品描述：" label-position="top" prop="remark" required>
          <view class="w-full pt-24rpx">
            <uv-textarea v-model="modelForm.remark" auto-height maxlength="500" placeholder="请输入您对产品的定义或想法" border="none"></uv-textarea>
          </view>
        </uv-form-item>
      </uv-form>
    </view>

    <view class="flex items-center justify-between px-32rpx fixed h-116rpx left-0 right-0 bottom-0 bg-#ffffff safety-2">
      <mt-button class="w-full" @click="handleSubmit">提交</mt-button>
    </view>
  </view>
</template>

<script setup>
import { productApplyLogproviderAddProductLogApp } from '@/subProduct/api/index';

const formRef = ref();
const modelForm = ref({
  productName: '',
  remark: ''
});
const rules = {
  productName: {
    type: 'string',
    required: true,
    message: '请输入产品名称',
    trigger: ['blur']
  },
  remark: {
    type: 'string',
    required: true,
    message: '请输入产品描述',
    trigger: ['blur']
  }
};

function handleSubmit() {
  formRef.value
    .validate()
    .then(() => {
      productApplyLogproviderAddProductLogApp(modelForm.value).then(() => {
        uni.showToast({
          icon: 'none',
          title: '操作成功',
          duration: 1000
        });
        setTimeout(() => {
          uni.navigateBack();
        }, 1000);
      });
    })
    .catch((err) => {});
}
</script>

<style lang="scss" scoped>
.forms {
  :deep(.uv-input) {
    height: 50rpx;
    padding: 0 12rpx !important;
  }
  :deep(.uv-textarea) {
    background: #f7f7f7 !important;
    .uni-textarea-wrapper {
      min-height: 100rpx;
    }
  }
  :deep(.uv-form) {
    .uv-form-item {
      font-size: 28rpx;
      margin-bottom: 16rpx;
      background-color: #ffffff;
      .uv-form-item__body {
        padding: 30rpx 32rpx;
      }
      .uv-form-item__body__left__content__label {
        font-size: 28rpx;
        color: #727687;
        padding-left: 8rpx;
      }
    }
  }
}
</style>
